#ifndef FILEDATAEXTRACTOR_H
#define FILEDATAEXTRACTOR_H

#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>
#include <string>

#include "FileHeader.h"
#include "CentralDirectory.h"

using namespace std;

typedef unsigned long ULONG;

class FileDataExtractor
{
public:

    FileHeader* createFileHeader(const char* file);

    CentralDirectory* create_cdirectory(FileHeader* header);

private:

    char* getName(const char* filepath);
    
    tm* getLastModifiedTime(const char *filepath);

    unsigned short calculate_modified_time(tm* time);

    unsigned short calculate_modified_date(tm* time);

    void makeLittleIndian(unsigned short& codedValue);
    
    long fileSize(FILE *input);
    
    void initCrcTable();
    
    ULONG reflect(ULONG ref, char ch);
    
    ULONG getCRC(unsigned char* buffer, ULONG bufsize);
};

#endif	/* FILEDATAEXTRACTOR_H */